<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="./vue.js"></script>
  <div id="app">
    <h3>count的值是：{{count}}</h3>
    <!-- 如果按钮是偶数，背景色就变成红色 -->
    <button @click="add(1,$event)">+1</button>
    <button @click="jian()">-1</button>
  </div>
  <script>
  const vm = new Vue({
    el:'#app',
    data:{
      tips:'123',
      count:0,
    },
    methods:{
      add(n,e) {
        this.count+= n;
        if (this.count %2 == 0 ) {
          e.target.style.backgroundColor = 'red',
          e.target.style.width=100 + 'px'
          console.log(e);
        }else {
          e.target.style.backgroundColor = ''
          e.target.style.width= 30 + 'px'
        }
      },
      jian() {
       if (this.count > 0 ) {
        this.count--
       }
      }
    }
  })
  </script>
</body>
</html>